package com.sgcc.lms.bean;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-11-27 17:37
 * @Description:
 */
@Component
public class User implements ApplicationContextAware {
    private ApplicationContext applicationContext;

    public User(){
        System.out.println("User... constructor...");
    };

    //对象创建并赋值之后调用
    @PostConstruct
    public void init(){
        System.out.println("User....@PostConstruct...");
    }

    //容器移除对象之前
    @PreDestroy
    public void detory(){
        System.out.println("User....@PreDestroy...");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
